{{extend "layout_admin.html"}}

{{block css}}
{{end}}

{{block title}}
<i class="fa fa-coffee fa-fw"></i> {{=title}}
{{end}}

{{block content}}
<input type="hidden" id="hid-proj-id" value="{{=proj_id}}"/>
<div class="row">
    <div class="col-lg-6 col-lg-offset-2">
        <div class="panel panel-info">
            <div class="panel-heading">
                <h3 class="panel-title">项目详细:</h3>
            </div>
            <div class="panel-body">
                <form class="form-horizontal">
                    <div class="form-group">
                        <label  class="col-lg-2 control-label">项目名称</label>
                        <div class="col-lg-9">
                            <input cj-required cj-range="[1,16]" class="form-control cj-validator" placeholder="项目名称" name="txt-proj-name" id="txt-proj-name" cj-name="项目名称" type="text" value="{{=proj_name}}" autofocus>
                        </div>
                    </div>

                    <div class="form-group">
                        <label  class="col-lg-2 control-label">项目描述</label>
                        <div class="col-lg-9">
                            <textarea name="txt-proj-desc" id="txt-proj-desc" class="form-control" rows="3">{{=proj_desc}}</textarea>
                        </div>
                    </div>
                </form>
                <div class="pull-left">
                <button class="btn btn-info" id="btn-add-users" data-toggle="modal" data-target="#user-modal">
                    <i class="fa fa-plus fa-fw"></i> 追加项目成员
                </button>
                </div>
                <div class="pull-right">
                    <button class="btn btn-success" id="btn-save"><i class="fa fa-save fa-fw"></i>  保存项目
                    </button>
                    {{if proj_id != 0:}}
                    <button class="btn btn-danger" id="btn-del"><i class="fa fa-trash-o fa-fw"></i>  删除项目
                    </button>
                    {{pass}}
                    <button class="btn btn-link" id="btn-back"> 返回</button>
                </div>
            </div> <!-- div pannel-body -->

            <table class="table table-striped" id="tb-users">
                <thead>
                    <th>#</th>
                    <th>用户名</th>
                    <th>真实姓名</th>
                    <th>Email</th>
                    <th>删除</th>
                    <th class="hidden"></th>
                </thead>
                <tbody>
                    {{order = 1}}
                    {{for user in proj_users:}}
                    <tr>
                        <td>{{=order}}</td>
                        <td>{{=user.name}}</td>
                        <td>{{=user.real_name}}</td>
                        <td>{{=user.email}}</td>
                        <td class="hidden">{{=user.id}}</td>
                        <td><button class="btn btn-danger btn-xs" onclick="del_user(this);"><i class="fa fa-trash-o fa-fw"></i>删除</button></td>
                    </tr>
                    {{order += 1}}
                    {{pass}}
                </tbody>
            </table>
            
        </div> <!-- div panel -->
    </div>
</div> <!-- div row -->

<!-- Modal -->
<div class="modal fade" id="user-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title" id="myModalLabel">请选择项目用户:</h4>
      </div>
      <div class="modal-body">
          <ul>
          </ul>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-primary" id="btn-sel-users">确定</button>
        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
{{end}}

{{block js}}
<script src="{{=url_for_static('chujue-js/chujue_validate.js')}}"></script>
<script src="{{=url_for_static('chujue-js/chujue_ajax.js')}}"></script>
<script src="{{=url_for_static('views_project_admin/edit.js')}}"></script>

<script type="text/javascript">
    $(function(){
        $("#btn-save").click(save_project);
        $("#btn-back").click(function(){
            location.href = "/admin/index";
        });
        $("#btn-del").click(del_project);

        $("#btn-add-users").click(display_users);
        $("#btn-sel-users").click(select_users);
    });
</script>
{{end}}

